04. Using new and delete
ND213 C03 L03 03.1 Using New And Delete HS
Workspace
This section contains either a workspace (it can be a Jupyter Notebook workspace or an online code editor work space, etc.) and it cannot be automatically downloaded to be generated here. Please access the classroom with your account and manually download the workspace to your local machine. Note that for some courses, Udacity upload the workspace files onto https://github.com/udacity , so you may be able to download them there.
Workspace Information:
- Default file path:
- Workspace type: jupyter-lab
- Opened files (when workspace is loaded): n/a
Reasons for overloading
new
and
delete
Now that we have seen how to overload the new and delete operators, let us summarize the major scenarios where it makes sense to do this:
-
The overloaded new operator function allows to add additional parameters . Therefore, a class can have multiple overloaded new operator functions. This gives the programmer more flexibility in customizing the memory allocation for objects.
-
Overloaded the new and delete operators provides an easy way to integrate a mechanism similar to garbage collection capabilities (such as in Java), as we will shorty see later in this course.
-
By adding exception handling capabilities into new and delete, the code can be made more robust.
-
It is very easy to add customized behavior, such as overwriting deallocated memory with zeros in order to increase the security of critical application data.
Outro
ND213 C03 L03 03.3 Using New And Delete HS